package mortal.game.resource
{
	import com.gengine.resource.*;
	import flash.utils.*;
	
	public class MusicsAndSoundsConfig extends Object
	{
		private var _musicsDic:Dictionary;
		private var _soundsDic:Dictionary;
		private static var _instance:MusicsAndSoundsConfig;
		
		public function MusicsAndSoundsConfig()
		{
			this._musicsDic = new Dictionary();
			this._soundsDic = new Dictionary();
			if (_instance != null)
			{
				throw new Error(" MusicsAndSoundsConfig 单例 ");
			}
			this.init();
			
		}
		
		private function write(param1:Object) : void
		{
			var _loc_4:Object = null;
			var _loc_5:String = null;
			var _loc_2:* = param1["musics"]["music"] as Array;
			var _loc_3:* = param1["sounds"]["sound"] as Array;
			for each (_loc_4 in _loc_2)
			{
				
				_loc_5 = _loc_4.mapId + "_" + _loc_4.sceneName;
				this._musicsDic[_loc_5] = _loc_4.fileName;
			}
			for each (_loc_4 in _loc_3)
			{
				
				this._soundsDic[_loc_4.type] = _loc_4.fileName;
			}
			
		}
		
		public function init() : void
		{
			var _loc_1:* = ConfigManager.instance.getObjectByFileName("musicsAndSounds.xml");
			this.write(_loc_1);
			
		}
		
		public function getMusicFileNameByMapId(param1:int, param2:String = "") : String
		{
			return this._musicsDic[param1 + "_" + param2] as String;
		}
		
		public function getSoundFileNameByType(param1:String) : String
		{
			return this._soundsDic[param1] as String;
		}
		
		public static function get instance() : MusicsAndSoundsConfig
		{
			if (_instance == null)
			{
				_instance = new MusicsAndSoundsConfig;
			}
			return _instance;
		}
		
	}
}
